package com.service.album.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dao.album.AlbumDao;
import com.entity.album.Album;
import com.entity.album.AlbumComment;
import com.entity.album.AlbumItems;
import com.entity.other.ShareType;
import com.service.album.AlbumService;
import com.util.dao.BasicDao;

@Service("albumService")
public class AlbumServiceImpl implements AlbumService{
	
	@Autowired
	private BasicDao basicDao;
	
	@Autowired
    private AlbumDao albumDao;

	public List<Album> getAllAlbum() throws Exception {
		return (List<Album>)basicDao.queryByExampleEntity(Album.class, new Album(), 0, 100);
	}

	public List<ShareType> getAllShareType() throws Exception {
		return (List<ShareType>)basicDao.queryByExampleEntity(ShareType.class, new ShareType(), 0, 10);
	}

	public void createAlbum(Album album) throws Exception {
		basicDao.saveOrUpdate(album);
	}

	public void saveAlbumItems(AlbumItems albumItems) throws Exception {
		        basicDao.saveOrUpdate(albumItems);
	}

	public AlbumItems getAlbumItemsById(int albumItemsId) throws Exception {
		return basicDao.queryById(AlbumItems.class, albumItemsId);
	}

	public List<AlbumItems> getAlbumItemsByAlbumId(int albumId)
			throws Exception {
		return albumDao.getAlbumItemsByAlbumId(albumId);
	}

	public Album getAlbumById(int albumId) throws Exception {
		return basicDao.queryById(Album.class, albumId);
	}

	public void saveAlbumComment(AlbumComment albumComment) throws Exception {
		basicDao.saveOrUpdate(albumComment);
	}
	
	

}
